package com.newgd.blockchain.demo.task;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.newgd.blockchain.demo.model.Trades;
import com.newgd.blockchain.demo.service.ITradesService;

import javax.annotation.Resource;

/**
 * Created by Niki on 2018/4/14 11:06
 */
public class TradesExecute implements  Runnable {
    @Resource
    ITradesService service;
    private JSONArray tradeses ;

    public TradesExecute(JSONArray tradeses) {
        this.tradeses = tradeses;
    }

    @Override
    public void run() {
        for (int i = 0; i < tradeses.size(); i++) {
            JSONObject object = tradeses.getJSONObject(i);
            Trades trades = Trades.jsonToTrades(object);
            service.save(trades);
        }
    }
}
